package cn.melonlib.nars.names.model.entity;

import cn.melonlib.cores.commons.model.entity.TenantRecordEntity;
import cn.melonlib.cores.model.anno.ModelComment;
import cn.melonlib.nars.names.model.enmus.NamesType;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import javax.persistence.*;

/**
 * 名称服务定义类
 */
@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties("parent")
public class MelonNames extends TenantRecordEntity {

    @ModelComment(value = "名称",required = true)
    private String name;

    @ModelComment("路径")
    @Column@Lob@Basic(fetch = FetchType.LAZY)@Type(type = "org.hibernate.type.TextType")
    private String path;


    @ManyToOne(cascade = {CascadeType.REFRESH},fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id",foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    @ModelComment("父目录")
    private MelonDirectory parent;

    @ModelComment("名称类型")
    @Enumerated(EnumType.STRING)
    private NamesType namesType=NamesType.DIRECTORY;

    public String exts() throws Exception{
        return null;
    }
}
